package com.ideaplugin.datamanager.controller;

import com.ideaplugin.datamanager.model.common.PageRequest;
import com.ideaplugin.datamanager.model.common.PageResult;
import com.ideaplugin.datamanager.model.common.PlainResult;
import com.ideaplugin.datamanager.model.request.CustomizedColumnInfoParam;
import com.ideaplugin.datamanager.model.response.TableInfoVo;
import com.ideaplugin.datamanager.model.response.UserAuthColumnVo;
import com.ideaplugin.datamanager.service.UserTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author zhaojingbo
 * @since 2023-06-07
 */
@RestController
@RequestMapping("/userTable")
public class UserTableController {

    @Autowired
    private UserTableService userTableService;


    @PostMapping("/pageUserAuthTable")
    public PageResult<TableInfoVo> pageUserAuthTable(@RequestBody PageRequest param) {
        return userTableService.pageUserAuthTable(param);
    }

    @GetMapping("/getUserAuthColumn")
    public PlainResult<UserAuthColumnVo> getUserAuthColumn(Long tableInfoId) {
        return new PlainResult<>(userTableService.getUserAuthColumn(tableInfoId));
    }

    @PostMapping("/saveUserCustomizedColumnInfo")
    public PlainResult<Boolean> saveUserCustomizedColumnInfo(@RequestBody CustomizedColumnInfoParam customizedColumnInfoParam) {
        return new PlainResult<>(userTableService.saveUserCustomizedColumnInfo(customizedColumnInfoParam));
    }

}
